<?php
class Tipogrupo extends AppModel {

	var $name = 'Tipogrupo';

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $hasMany = array(
		'Grupo' => array(
			'className' => 'Grupo',
			'foreignKey' => 'tipogrupo_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	
	/*
	function getCountGrid($like){
		if($like!=null)
			$condicion = " AND ".$like." ";
		else $condicion = "";
		$res = $this->query("
			SELECT	count(grupo.id)	as count					
			FROM	grupos grupo, iglesias iglesia, tipogrupo tipogrupo
			WHERE	grupo.tipogrupo_id = tipogrupo.id
			$condicion");	
		return $res[0][0]["count"];
	}
	function getUsersGrid($orden,$limit,$like){
		if($like!=null)
			$condicion = " AND ".$like." ";
		else $condicion = "";
		$res = $this->query("
			SELECT  user.id, user.rut, user.nombre1, user.nombre2, user.apellido1, user.apellido2, 
			iglesia.nombre, user.direccion, user.fono_fijo, user.fono_movil, 
			user.email, user.created, user.modified					
			FROM	users user, iglesias iglesia 
			WHERE	iglesia.id = user.iglesia_id
			$condicion
			ORDER BY 	$orden  LIMIT $limit;");	
		return $res;
	}*/
}
?>